<template>
	<div>
		<el-transfer :titles="titles"
		filterable
		:data="users"
		:props="props"
		v-model="values"></el-transfer>
		<el-button size="small" type="success" style="margin-left: 20px;" plain @click="save">保存</el-button>
	</div>
</template>

<script>
	import { get, post } from '@/plugins/axios'
	export default {
		name: 'userList',
		created() {
			this.roleId =this.$route.query.roleId;
			this.getData();

		},
		data() {
			return {
				titles: ['所有用户', '关联用户'],
				users:[],
				props:{key:'id',label:'name'},
				values:[],
				roleId:null
			}
		},
		methods: {
			getData(){
				get('/ums-role-user/getData',{
					roleId:this.roleId,
					active:1,
				},response=>{
					this.users = response.users;
					console.log(response)
					response.values.forEach(item=>{
						this.values.push(item.userId)
					})
				})
			},
			save(){
				post('/ums-role-user/save',{roleId:this.roleId,userIds:this.values},response=>{
					console.log("111111")
				})
			}
		},
	}
</script>

<style>
</style>
